<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function solve(a){
            let arr = a
            let newArr = arr.split("")
            var obj = {}; 
            for(var i= 0, l = newArr.length; i< l; i++){ 
                var item = newArr[i]; 
                obj[item] = (obj[item] +1 ) || 1; 
            }
        return obj
        }
        
        let obj = "ababc"
        
        console.log(solve(obj))
    </script>
</body>
</html>